import React from 'react';
import '../assets/less/add.less';

class AddTodo extends React.Component {
	
	onKeyDown(e) {
		if(e.keyCode == 13 && e.target.value.length > 0) {
			console.log(e.target.value);
			this.props.addTodo(e.target.value);
			e.target.value = '';
		}
	}
	
	render() {
		return (
			<div className="head">
				<div className="head-container">
					<span className="head-title">ToDoList</span>
					<input type="text" placeholder="添加ToDo" onKeyDown={this.onKeyDown.bind(this)} />
				</div>
			</div>
		)
	}
}

export default AddTodo;